package cn.iocoder.yudao.module.security.dal.mysql.device;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.security.dal.dataobject.device.SecurityDeviceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.security.controller.admin.device.vo.*;

/**
 * 设备接入 Mapper
 *
 * @author cai
 */
@Mapper
public interface SecurityDeviceMapper extends BaseMapperX<SecurityDeviceDO> {

    default PageResult<SecurityDeviceDO> selectPage(SecurityDevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SecurityDeviceDO>()
                .likeIfPresent(SecurityDeviceDO::getIpAddress, reqVO.getIpAddress())
                .likeIfPresent(SecurityDeviceDO::getMacAddress, reqVO.getMacAddress())
                .eqIfPresent(SecurityDeviceDO::getSourceType, reqVO.getSourceType())
                .betweenIfPresent(SecurityDeviceDO::getLastOnlineTime, reqVO.getLastOnlineTime())
                .betweenIfPresent(SecurityDeviceDO::getLastOfflineTime, reqVO.getLastOfflineTime())
                .eqIfPresent(SecurityDeviceDO::getOnlineHour, reqVO.getOnlineHour())
                .eqIfPresent(SecurityDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())
                .eqIfPresent(SecurityDeviceDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SecurityDeviceDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SecurityDeviceDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(SecurityDeviceDO::getDeviceUsername, reqVO.getDeviceUsername())
                .eqIfPresent(SecurityDeviceDO::getDevicePassword, reqVO.getDevicePassword())
                .eqIfPresent(SecurityDeviceDO::getDeviceCpu, reqVO.getDeviceCpu())
                .eqIfPresent(SecurityDeviceDO::getDeviceMemory, reqVO.getDeviceMemory())
                .eqIfPresent(SecurityDeviceDO::getDeviceDisk, reqVO.getDeviceDisk())
                .eqIfPresent(SecurityDeviceDO::getDeviceAlias, reqVO.getDeviceAlias())
                .eqIfPresent(SecurityDeviceDO::getDeviceLocation, reqVO.getDeviceLocation())
                .orderByDesc(SecurityDeviceDO::getId));
    }

}